<?php

namespace app\common\exception;

use Exception;
use think\exception\Handle;
use think\exception\HttpException;

class Http extends Handle
{
    public function render(Exception $e)
    {
        // 请求异常
        if ($e instanceof HttpException && request()->isGet()) {
            switch ($e->getStatusCode()) {
                case 404:
                    return redirect(url('404'));
                    break;
                default:
                    break;
            }
            return response($e->getMessage());
        }
        // 其他错误交给系统处理
        return parent::render($e);
    }

}